/**
 * @param {string} s
 * @return {string}
 */
const maskPII = function(s) {
    const at = s.indexOf("@");
    if (at >= 0) {
        return (s.charAt(0) + "*****" + s.substring(at-1)).toLowerCase();
        // return (s[0] + "*****" + s.substring(at-1)).toLowerCase();
    }
    // s = s.replaceAll("[^0-9]", "");
    let sb = "";
    for (let i=0; i<s.length; ++i) {
        const c = s.charAt(i);
        // if ('0' <= c <= '9') 结果错误
        if ('0' <= c && c <= '9') {
            sb += c;
        }
    }
    s = sb.toString();
    const country = ["", "+*-", "+**-", "+***-"];
    return country[s.length-10] + "***-***-" + s.substring(s.length-4); // 可以
    // return country[s.length-10] + "***-***-" + s[s.length-4:]; 报错！
};

// let s = "LeetCode@LeetCode.com";
let s = "1(234)567-890";
console.log(maskPII(s));
console.log("*" * 5);
console.log("*****");
console.log(s.charAt(0));
s = s.replaceAll("[^0-9]", "");
console.log(s);
const country = new Array(["", "+*-", "+**-", "+***-"]);
console.log(country);